package com.cet.spring_batch_study.jobs.endOfDay;

import org.springframework.batch.core.JobParameters;
import org.springframework.batch.core.JobParametersBuilder;
import org.springframework.batch.core.JobParametersIncrementer;

/**
 * @author NSOC
 */
public class LoopTimesIncrementer implements JobParametersIncrementer {

    @Override
    public JobParameters getNext(JobParameters parameters) {
        if (parameters==null || parameters.isEmpty()) {
            return new JobParametersBuilder().addLong("loop.times", 1L).toJobParameters();
        }
        long id = parameters.getLong("loop.times",1L) + 1;
        return new JobParametersBuilder().addLong("loop.times", id).toJobParameters();
    }
}